package com.shux.springsource.beanpost;

import java.lang.reflect.Constructor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;

/**
 * 描述：
 * 
 * <pre>HISTORY
 * ****************************************************************************
 *  ID   DATE           PERSON          REASON
 *  1    2018年1月17日      Simba.Hua         Create
 * ****************************************************************************
 * </pre>
 * @author Simba.Hua
 */
public class MyInstantiationAwareBeanPostProcessorAdapter extends
		InstantiationAwareBeanPostProcessorAdapter {
	@Override
	public Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) throws BeansException {
		System.out.println("执行MyInstantiationAwareBeanPostProcessorAdapter的determineCandidateConstructors，默认实例化前自定义实例后调用，用于自定义构造函数");
		return null;
	}
	@Override
	public Object getEarlyBeanReference(Object bean, String beanName)
			throws BeansException {
		System.out.println("执行MyInstantiationAwareBeanPostProcessorAdapter的getEarlyBeanReference");
		return super.getEarlyBeanReference(bean, beanName);
	}

	@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass,
			String beanName) throws BeansException {
		System.out.println("执行MyInstantiationAwareBeanPostProcessorAdapter的postProcessBeforeInstantiation(Class<?> beanClass,String beanName)，实例化前调用");
		return super.postProcessBeforeInstantiation(beanClass, beanName);
	}

	@Override
	public boolean postProcessAfterInstantiation(Object bean, String beanName)
			throws BeansException {
		System.out.println("执行MyInstantiationAwareBeanPostProcessorAdapter的postProcessAfterInstantiation(Object bean, String beanName)，实例化后属性设置值前调用");
		return super.postProcessAfterInstantiation(bean, beanName);
	}

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName)
			throws BeansException {
		System.out.println("执行MyInstantiationAwareBeanPostProcessorAdapter的postProcessBeforeInitialization(Object bean, String beanName)，属性设置后，init方法调用前调用");
		return super.postProcessBeforeInitialization(bean, beanName);
	}

	@Override
	public Object postProcessAfterInitialization(Object bean, String beanName)
			throws BeansException {
		System.out.println("执行MyInstantiationAwareBeanPostProcessorAdapter的postProcessAfterInitialization(Object bean, String beanName)，init方法调用后执行");
		return super.postProcessAfterInitialization(bean, beanName);
	}

}
